package org.EasyDevelop.Bean;

import org.EasyDevelop.Utils.PropertiesUtils;

import java.util.HashMap;
import java.util.Map;

public class Constants {

    public static String ENABLE_VALID;
    public static String ENABLE_BUILDER;
    public static String ENABLE_LOGGING;

    public static Map<String,String> PATH_MAP = new HashMap<>();
    public static Map<String,String> PACKAGAE_MAP = new HashMap<>();
    public static Map<String,String> SUFFIX_MAP = new HashMap<>();
    public static Map<String,String> IGNORE_MAP = new HashMap<>();

    public static String PATH_UTILS;
    public static String PACKAGE_UTILS;
    public static Boolean IGNORE_TABLE_PREFIX;
    public static String IGNORE_TABLE_PREFIX_NAME;
    public static String PATH_JAVA = "java";
    public static String PATH_RESOURCE = "resources";
    public static String PATH_SRC = "src/main";
    public static String PACKAGE_BASE;
    public static String PACKAGE_PO;
    public static String PACKAGE_QUERY;
    public static String PACKAGE_MAPPER;
    public static String PACKAGE_ENTITY;
    public static String PACKAGE_SERVICE;
    public static String PACKAGE_SERVICE_IMPL;
    public static String PACKAGE_ENTITY_VO_PAGINATIONRESVO;

    public static String PACKAGE_ENTITY_VO_RESPONSE_VO;
    public static String PACKAGE_CONTROLLER;
    public static String PACKAGE_CONTROLLER_ADVICE;
    public static String PACKAGE_CONTROLLER_BASE;
    public static String PACKAGE_EXCEPTION;
    public static String PATH_BASE;
    public static String PATH_PO;
    public static String PATH_QUERY;
    public static String PATH_MAPPER;
    public static String PATH_ENTITY;
    public static String PATH_SERVICE;
    public static String PATH_SERVICE_IMPL;
    public static String PATH_RESOURCE_MAPPER_XML;
    public static String PATH_ENTITY_VO_PAGINATIONRESVO;
    public static String PATH_ENTITY_VO_RESPONSE_VO;
    public static String PATH_CONTROLLER;
    public static String PATH_CONTROLLER_ADVICE;
    public static String PATH_CONTROLLER_BASE;
    public static String PATH_EXCEPTION;

    public static String AUTHOR;
    public static String JAVA_SUFFIX = ".java";
    public static String JAVA_TYPE_DATE = "Date";
    public static String JAVA_TYPE_STRING = "String";
    public static String XML_SUFFIX = ".xml";
    public static String[] IGNORE_BEAN_TO_JSON_FILED;
    public static String IGNORE_BEAN_TO_JSON_EXPRESSION;
    public static String IGNORE_BEAN_TO_JSON_CLASS;
    public static String DATE_SERIALIZABLE_EXPRESSION;
    public static String DATE_SERIALIZABLE_CLASS;
    public static String DATE_DESERIALIZABLE_EXPRESSION;
    public static String DATE_DESERIALIZABLE_CLASS;


    static {
        //SUFFIX
        SUFFIX_MAP.put("queryParam",PropertiesUtils.getValue("suffix.bean.queryParam"));
        SUFFIX_MAP.put("queryParamFuzzy",PropertiesUtils.getValue("suffix.bean.queryParam.fuzzy"));
        SUFFIX_MAP.put("timeStart",PropertiesUtils.getValue("suffix.bean.query.time.start"));
        SUFFIX_MAP.put("timeEnd",PropertiesUtils.getValue("suffix.bean.query.time.end"));
        SUFFIX_MAP.put("mappers",PropertiesUtils.getValue("suffix.mappers"));
        SUFFIX_MAP.put("controller",PropertiesUtils.getValue("suffix.controller"));
        SUFFIX_MAP.put("service",PropertiesUtils.getValue("suffix.service"));
        SUFFIX_MAP.put("serviceImpl",PropertiesUtils.getValue("suffix.serviceImpl"));
        SUFFIX_MAP.put("java",".java");

        //IGNORE
        IGNORE_MAP.put("tablePrefix",PropertiesUtils.getValue("ignore.table.prefix"));
        IGNORE_MAP.put("tablePrefixName",PropertiesUtils.getValue("ignore.table.prefix.name"));
        IGNORE_MAP.put("beanToJsonFiled",PropertiesUtils.getValue("ignore.bean.toJson.filed"));
        IGNORE_MAP.put("beanToJsonExpression",PropertiesUtils.getValue("ignore.bean.toJson.expression"));
        IGNORE_MAP.put("beanToJsonClass",PropertiesUtils.getValue("ignore.bean.toJson.class"));

        //PATH

        //ENABLE_VALID
        ENABLE_VALID = PropertiesUtils.getValue("valid.enabled");
        ENABLE_BUILDER = PropertiesUtils.getValue("builder.enabled");
        ENABLE_LOGGING = PropertiesUtils.getValue("logging.enabled");


        IGNORE_TABLE_PREFIX = Boolean.valueOf(PropertiesUtils.getValue("ignore.table.prefix"));
        IGNORE_TABLE_PREFIX_NAME = PropertiesUtils.getValue("ignore.table.prefix.name");

        PATH_BASE = PropertiesUtils.getValue("path.base") + "/" + PATH_SRC + "/" + PATH_JAVA;

        PACKAGE_BASE = PropertiesUtils.getValue("package.base").replace("/",".");


        PACKAGE_PO = PACKAGE_BASE + "." + PropertiesUtils.getValue("package.po").replace("/",".");

        PACKAGE_QUERY = PACKAGE_BASE + "." + PropertiesUtils.getValue("package.queryParam").replace("/",".");
        PACKAGE_UTILS = PACKAGE_BASE + "." + PropertiesUtils.getValue("package.utils").replace("/",".");
        PACKAGE_MAPPER= PACKAGE_BASE + "." + PropertiesUtils.getValue("package.mappers");
        PACKAGE_ENTITY= PACKAGE_BASE + "." + PropertiesUtils.getValue("package.entity");
        PACKAGE_SERVICE= PACKAGE_BASE + "." + PropertiesUtils.getValue("package.service");
        PACKAGE_SERVICE_IMPL= PACKAGE_SERVICE + "." + PropertiesUtils.getValue("package.service.impl");
        PACKAGE_ENTITY_VO_PAGINATIONRESVO = PACKAGE_BASE + "." + PropertiesUtils.getValue("package.paginationResVo");
        PACKAGE_ENTITY_VO_RESPONSE_VO = PACKAGE_BASE + "." + PropertiesUtils.getValue("package.responseVo");
        PACKAGE_CONTROLLER = PACKAGE_BASE + "." + PropertiesUtils.getValue("package.controller");
        PACKAGE_CONTROLLER_ADVICE = PACKAGE_CONTROLLER + "." + PropertiesUtils.getValue("package.controller.controllerAdvice");
        PACKAGE_CONTROLLER_BASE = PACKAGE_CONTROLLER + "." + PropertiesUtils.getValue("package.controller.baseController");
        PACKAGE_EXCEPTION = PACKAGE_BASE + "." + PropertiesUtils.getValue("package.exception");


        PATH_PO = PATH_BASE + "/" + PACKAGE_PO.replace(".","/");
        PATH_QUERY = PATH_BASE + "/" + PACKAGE_QUERY.replace(".","/");
        PATH_UTILS = PATH_BASE + "/" + PACKAGE_UTILS.replace(".","/");
        PATH_MAPPER = PATH_BASE + "/" + PACKAGE_MAPPER.replace(".","/");
        PATH_ENTITY= PATH_BASE + "/" + PACKAGE_ENTITY.replace(".","/");
        PATH_SERVICE= PATH_BASE + "/" + PACKAGE_SERVICE.replace(".","/");
        PATH_SERVICE_IMPL= PATH_SERVICE + "/" + PropertiesUtils.getValue("package.service.impl").replace(".","/");
        PATH_ENTITY_VO_PAGINATIONRESVO = PATH_BASE + "/" + PACKAGE_ENTITY_VO_PAGINATIONRESVO.replace(".","/");
        PATH_ENTITY_VO_RESPONSE_VO = PATH_BASE + "/" + PACKAGE_ENTITY_VO_RESPONSE_VO.replace(".","/");
        PATH_CONTROLLER = PATH_BASE + "/" + PACKAGE_CONTROLLER.replace(".","/");
        PATH_CONTROLLER_BASE = PATH_BASE + "/" + PACKAGE_CONTROLLER_BASE.replace(".","/");
        PATH_CONTROLLER_ADVICE = PATH_BASE + "/" + PACKAGE_CONTROLLER_ADVICE.replace(".","/");
        PATH_EXCEPTION = PATH_BASE + "/" + PACKAGE_EXCEPTION.replace(".","/");

        String xml = PropertiesUtils.getValue("mappers.xml");
        String str = Boolean.valueOf(PropertiesUtils.getValue("mappers.isUsedPackageBase"))?PACKAGE_BASE + "." + xml:xml;
        PATH_RESOURCE_MAPPER_XML = PropertiesUtils.getValue("path.base") + "/" + PATH_SRC + "/" + PATH_RESOURCE + "/" + str.replace(".", "/");


        AUTHOR = PropertiesUtils.getValue("author");

        IGNORE_BEAN_TO_JSON_FILED = PropertiesUtils.getValue("ignore.bean.toJson.filed").split(",");
        IGNORE_BEAN_TO_JSON_EXPRESSION = PropertiesUtils.getValue("ignore.bean.toJson.expression");
        IGNORE_BEAN_TO_JSON_CLASS = PropertiesUtils.getValue("ignore.bean.class");
        DATE_SERIALIZABLE_EXPRESSION = PropertiesUtils.getValue("bean.date.serializable.expression");
        DATE_SERIALIZABLE_CLASS = PropertiesUtils.getValue("bean.date.serializable.class");
        DATE_DESERIALIZABLE_EXPRESSION = PropertiesUtils.getValue("bean.date.deserializable.expression");
        DATE_DESERIALIZABLE_CLASS = PropertiesUtils.getValue("bean.date.deserializable.class");


    }

    public static String[] SQL_DATE_TIME_TYPES = new String[]{"datetime","timestamp"};
    public static String[] SQL_DATE_TYPES = new String[]{"date"};
    public static String[] SQL_DECIMAL_TYPES = new String[]{"decimal","double","float"};
    public static String[] SQL_STRING_TYPES = new String[]{"char","varchar","text","mediumtext","longtext","enum"};
    public static String[] SQL_INTEGER_TYPES = new String[]{"int","tinyint"};
    public static String[] SQL_LONG_TYPES = new String[]{"bigint"};

    public static void main(String[] args) {
        System.out.println(PATH_CONTROLLER);
        System.out.println(PATH_CONTROLLER_BASE);
        System.out.println(PATH_CONTROLLER_ADVICE);
        System.out.println(PACKAGE_CONTROLLER);
        System.out.println(PACKAGE_CONTROLLER_BASE);
        System.out.println(PACKAGE_CONTROLLER_ADVICE);
        System.out.println(PATH_EXCEPTION);
        System.out.println(PACKAGE_EXCEPTION);

    }
}
